package com.qiusuo0226.core.controller;

import com.qiusuo0226.core.pojo.query.UserInfoAddBean;
import com.qiusuo0226.core.service.UserInfoService;
import com.qiusuo0226.mvc.util.JsonResultModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author qiusuo
 * @date 2023/6/17 23:00
 */
@RestController
@CrossOrigin
@RequestMapping("/manager/userInfo")
@Slf4j
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 新增用户
     * @param bean
     * @return
     */
    @PostMapping("/add")
    public JsonResultModel add(@RequestBody @Valid UserInfoAddBean bean) {
        if (null != bean) {
            try {
                bean.decrypt();
            } catch (Exception e) {
                log.error("", e);
                return JsonResultModel.paramsError("参数解密异常");
            }

            return userInfoService.add(bean);

        }
        return JsonResultModel.requestError();
    }


}
